package com.nts.bupna.model;

import com.nts.bupna.model.exc.UnknownVariableException;

//TODO make model classes immutable, add builders for the parser to use for construction
public class Process implements Scoped, Container<Activity> {

    private String name;
    private String packageName;
    private Imports imports;
    private Vars vars;
    private Receive receive;
    private Reply reply;
    private Activity activity;

    @Override
    public String toString() {
        return "Process [name=" + name + ", packageName=" + packageName
        + ", imports=" + imports + ", vars=" + vars + ", receive="
        + receive + ", activity=" + activity + "]";
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public void setName(final String name) {
        this.name = name;
    }

    public Activity getActivity() {
        return activity;
    }

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(final String packageName) {
        this.packageName = packageName;
    }

    public Receive getReceive() {
        return receive;
    }

    public void setReceive(final Receive receive) {
        this.receive = receive;
    }

    public Reply getReply() {
        return reply;
    }

    public void setReply(final Reply reply) {
        this.reply = reply;
    }

    public Imports getImports() {
        return imports;
    }

    public void setImports(final Imports imports) {
        this.imports = imports;
    }

    public Vars getVars() {
        return vars;
    }

    public void setVars(final Vars vars) {
        this.vars = vars;
    }

    @Override
    public Var getVariable(final String varName) {
        for (final Var var : vars) {
            if (var.getName().equals(varName)) {
                return var;
            }
        }
        throw new UnknownVariableException(varName, this);
    }

    @Override
    public void add(final Activity mainActivity) {
        activity = mainActivity;
    }
}